package com.android.lovingpet.common.userinfo;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.util.Log;

import com.android.lovingpet.common.postlist.PostListFragment;

public class PagerAdapter extends FragmentPagerAdapter {

    private String[] title = new String[] {"爱宠日记", "相册"};
    private int userId;
    private PostListFragment postListFragment;

    public PagerAdapter(FragmentManager fm, int userId) {
        super(fm);
        this.userId = userId;
    }

    @Override
    public Fragment getItem(int position) {
        if (position == 0) {
            if (postListFragment == null) {
                postListFragment = PostListFragment.newInstance(1, userId);
            }
            return postListFragment;
        } else {
            return PostListFragment.newInstance(0, 4);//相册fragment，没还做
        }
    }

    @Override
    public int getCount() {
        return 2;
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return title[position];
    }
}
